home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Macromedia Multimedia Showcase 5.1
/
Macromedia - Multimedia Showcase 5.1 (Macromedia) (1996).ISO
/
pc
/
media
/
shared.dir
/
02123_Script_Scrolling Text Object
< prev
next >
Wrap
Text File
|
1996-03-28
|
8KB
|
225 lines
-- script for "Scrolling Text Object"
property scrollingTextChannel, scrollTop, scrollBottom, scrollHeight, ¼
sliderHeight, sliderTop, sliderBottom, sliderLoc, ¼
scrollUpButtonSprite, scrollDownButtonSprite, scrollSliderSprite, ¼
defaultVoff, maxVoff, sliderRange, maxTop, theScrollBarSprite
global gNavObj
on birth me, textChannel
-- The various buttons (up, down, and slider) are added dynamically, based
-- on the location of the slider bar. The text is presumed to be in
-- channel 6, unless another channel is specified. The top mask should
-- be in channel 16, and the bottom mask in channel 17. If these masks
-- are not found, then the bottom and top of the scroll buttons will be
-- used to determine top and bottom of scrollable areas.
global sBirthPtr, tBirthPtr, sDeathPtr, tDeathPtr, castIdPtr, scriptPtr
set scrollHeight = 0
set scrollSliderSprite = 0
set defaultVoff = 5
set maxVoff = 40
set buttonList = [ "bUp", "bDown", "bDrag" ]
set scriptList = [ "doScrollTextUp", "doScrollTextDown", "doSlideText" ]
if textChannel = "" or voidP(textChannel) or textChannel = 0 then
set scrollingTextChannel = 6
else
set scrollingTextChannel = value(textChannel)
end if
set scrollUpButtonSprite = 30
set scrollDownButtonSprite = 31
set scrollSliderSprite = 32
set myEvent = string( the curEvent of gNavObj )
set birthScene = item sBirthPtr of myEvent
put birthScene into item sDeathPtr of myEvent
put "end" into item tDeathPtr of myEvent
repeat with buttonNum = 1 to count(buttonList)
put getAt(buttonList,buttonNum) into item castIdPtr of myEvent
-- the #Instant causes a response on mouseDown, instead of on mouseUp
put (getAt(scriptList,buttonNum) && "#Instant") into item scriptPtr of myEvent
-- put " in scrolling text object"
DrawBtn (gNavObj, myEvent, "#AddScrollingText")
end repeat
return me
end birth
on kill me
puppetSprite scrollingTextChannel, FALSE
if scrollSliderSprite > 0 then puppetSprite scrollSliderSprite,FALSE
set scrollHeight = 0
set scrollingTextChannel = 0
end kill
--
on InitScrollingText me
if scrollingTextChannel = 0 then
return -1
end if
set scrollBarOffset = 16
puppetsprite scrollingTextChannel, TRUE
set scrollHeight = the height of cast (the castNum of sprite scrollingTextChannel)
set myTopMaskSprite = the topMaskSprite of gNavObj
set myBottomMaskSprite = the bottomMaskSprite of gNavObj
set topMaskCast = the castNum of sprite myTopMaskSprite
set bottomMaskCast = the castNum of sprite myBottomMaskSprite
set firstBtn = the firstBtnSprite of gNavObj
set lastBtn = the lastBtnSprite of gNavObj
if topMaskCast = 0 then
set topMaskCast = the castNum of sprite scrollUpButtonSprite
set myTopMaskSprite = scrollUpButtonSprite
end if
if bottomMaskCast = 0 then
set bottomMaskCast = the castNum of sprite scrollDownButtonSprite
set myBottomMaskSprite = scrollDownButtonSprite
end if
if scrollSliderSprite > 0 then puppetSprite scrollSliderSprite,TRUE
set scrollTop = the bottom of sprite myTopMaskSprite
set scrollBottom = the top of sprite myBottomMaskSprite
set theScrollBarSprite = the scrollBarSprite of gNavObj
set maxTop = scrollBottom - scrollHeight
set sliderRange = scrollTop - maxTop
set sliderHeight = the height of sprite theScrollBarSprite - (scrollBarOffset * 2)
set sliderTop = the top of sprite theScrollBarSprite + scrollBarOffset
set sliderBottom = the bottom of sprite theScrollBarSprite - scrollBarOffset
set sliderLoc = 0
end InitScrollingText
--
on doScrollTextUp
if objectP(the scrollingTextObj of gNavObj) then ScrollTextUp(the scrollingTextObj of gNavObj)
else put "no scrollingTextObj"
end doScrollTextUp
on ScrollTextUp me
if scrollHeight = 0 then InitScrollingText(me)
set textSprite = scrollingTextChannel
if textSprite > 0 then
Unhilite(gNavObj)
set mySprite = the clickOn
set vOff = 10
set currentTop = (the top of sprite textSprite)
if (currentTop + vOff) > scrollTop then
set vDelta = scrollTop - currentTop
else
set vDelta = vOff
end if
set the locV of sprite textSprite = the locV of sprite textSprite + vDelta
updateSlider(me)
set startTimeDown = the ticks
repeat while the mouseDown
if rollover(mySprite) then
set currentTop = (the top of sprite textSprite)
if (currentTop + vOff) > scrollTop then
set vDelta = scrollTop - currentTop
else
set vDelta = vOff
end if
set the locV of sprite textSprite = the locV of sprite textSprite + vDelta
updateSlider(me)
end if
if vOff < maxVoff then
set halfSecsDown = ((the ticks - startTimeDown) / 30) + 1
set vOff = defaultVOff * halfSecsDown
if vOff > maxVoff then set vOff = maxVoff
end if
end repeat
set the timingOut of gNavObj = FALSE
end if
end ScrollTextUp
--
on doScrollTextDown
if objectP(the scrollingTextObj of gNavObj) then ScrollTextDown(the scrollingTextObj of gNavObj)
else put "no scrollingTextObj"
end doScrollTextUp
on ScrollTextDown me
if scrollHeight = 0 then InitScrollingText(me)
set textSprite = scrollingTextChannel
if textSprite > 0 then
Unhilite(gNavObj)
set mySprite = the clickOn
set vOff = defaultVoff
set currentBottom = (the bottom of sprite textSprite)
if (currentBottom - vOff) < scrollBottom then
set vDelta = currentBottom - scrollBottom
else
set vDelta = vOff
end if
set the locV of sprite textSprite = the locV of sprite textSprite - vDelta
updateSlider(me)
set startTimeDown = the ticks
repeat while the mouseDown
if rollover(mySprite) then
set currentBottom = (the bottom of sprite textSprite)
if (currentBottom - vOff) < scrollBottom then
set vDelta = currentBottom - scrollBottom
else
set vDelta = vOff
end if
set the locV of sprite textSprite = the locV of sprite textSprite - vDelta
updateSlider(me)
end if
if vOff < maxVoff then
set halfsecsDown = ((the ticks - startTimeDown) / 30) + 1
set vOff = defaultVOff * halfSecsDown
if vOff > maxVoff then set vOff = maxVoff
end if
end repeat
set the timingOut of gNavObj = FALSE
end if
end ScrollTextDown
--
on updateSlider me
if scrollSliderSprite > 0 then
updateStage
set curTop = the top of sprite scrollingTextChannel
set percentDown = 100 - (((curTop - maxTop) * 100) / sliderRange)
set sliderVloc = sliderTop + ((sliderHeight * percentDown) / 100)
set the locV of sprite scrollSliderSprite = sliderVloc
updateStage
end if
end updateSlider
--
on doSlideText
if objectP(the scrollingTextObj of gNavObj) then SlideText(the scrollingTextObj of gNavObj)
end doScrollTextUp
on SlideText me
if scrollHeight = 0 then InitScrollingText(me)
set textSprite = scrollingTextChannel
set scrollFactor = (float(sliderRange) / sliderHeight)
if textSprite > 0 then
Unhilite(gNavObj)
set mySprite = the clickOn
set oldV = the locV of sprite mySprite
set offsetFromTop = (the top of sprite scrollingTextChannel - maxTop)
set maxTextRegV = (the locV of sprite scrollingTextChannel - offsetFromTop)
repeat while the mouseDown
if rollover(theScrollBarSprite) or rollover(mySprite) ¼
or rollover(scrollDownButtonSprite) or rollover(scrollUpButtonSprite) then
set newV = the mouseV
if newV < sliderTop then
set newV = sliderTop
else
if newV > sliderBottom then set newV = sliderBottom
end if
set the locV of sprite mySprite = newV
set newSliderPixelsUp = sliderBottom - newV
set textOffsetV = (newSliderPixelsUp * scrollFactor)
set newTextV = maxTextRegV + TextOffsetV
set the locV of sprite scrollingTextChannel = newTextV
updateStage
set oldV = newV
end if
end repeat
set the timingOut of gNavObj = FALSE
end if
end KillScrollingText